<div>
	<h1>Giỏ hàng</h1>
    <script type="text/javascript">
    	function CapNhat(id)
		{
			var sl = document.getElementById("sl"+id).value;
			location.href = "./pages/xlCapNhatGioHang.php?id="+id+"&sl="+sl;
		}
    </script>
	<table id="DSGioHang" cellspacing="0" cellpadding="5">
    	<tr>
       		<th>STT</th>
            <th>Sản phẩm</th>
            <th>Hình ảnh</th>
            <th>Giá</th>
            <th>Số lượng</th>
            <th>Thao tác</th>
        </tr>
        <?php
			$thanhtien = 0;
			if(isset($_SESSION["giohang"]))
			{
				for($i = 0; $i < count($_SESSION["giohang"]); $i++)
				{
					$id = $_SESSION["giohang"][$i];
					$sql = "SELECT * FROM dt WHERE madt = ".$id;
					$result = DataProvider::ExecuteQuery($sql);
					$row = mysql_fetch_array($result);
					?>
						 <tr>
							<td><?php echo $i + 1; ?></td>
							<td><?php echo $row["tendt"];?></td>
							<td>
								<img src="./<?php echo $row["hinh"]; ?>" height="50" />
							</td>
							<td><?php echo $row["gia"]; ?> VND</td>
							<td>
								<input type="text" id="sl<?php echo $id; ?>" value="<?php echo $_SESSION["soluong"][$i]; ?>" />
							</td>
							<td>
								<img src="./images/Layout/update.png" height="32" onclick="CapNhat(<?php echo $id;?>)" />
								&nbsp;&nbsp;
								<a href="./pages/xlXoaGioHang.php?id=<?php echo $id;?>">
									<img src="./images/Layout/delete.png" height="32" />
								</a>
							</td>
						</tr>
					<?php
					$thanhtien += $_SESSION["soluong"][$i] * $row["gia"];
				}
			}
		?>
    </table>
    <h2>Tổng thành tiền: <font color="#FF0000"><i><?php echo $thanhtien; ?> VNĐ</i></font></h2>
    <?php
		if(isset($_SESSION["giohang"]))
		{
			?>
                <a href="./pages/xlThanhToan.php">
                    <img src="./images/Layout/thanhtoan.png" width="75" />
                </a>            
            <?php
		}
	?>
</div>